﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

namespace Infraestructure.CrossCutting.Security
{
    public interface IMembershipManager
    {
        /// <summary>
        /// The unique identifier from the membership data source for the user logged.
        /// </summary>
        object ProviderUserKey { get; }

        /// <summary>
        /// The user is logged
        /// </summary>
        MembershipUser User { get; }
        
        /// <summary>
        /// Adds a new membership user to the data source.
        /// </summary>
        /// <param name="username">The user name for the new user. </param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <param name="passwordQuestion">The password question for the new user.</param>
        /// <param name="passwordAnswer">The password answer for the new user</param>
        /// <returns>A MembershipUser object populated with the information for the newly created user.</returns>
        MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer);

        /// <summary>
        /// Adds a new membership user to the data source.
        /// </summary>
        /// <param name="username">The user name for the new user. </param>
        /// <param name="password">The password for the new user.</param>
        /// <returns>A MembershipUser object populated with the information for the newly created user.</returns>
        MembershipUser CreateUser(string username, string password);

        /// <summary>
        /// Adds a new membership user to the data source.
        /// </summary>
        /// <param name="username">The user name for the new user. </param>
        /// <param name="password">The password for the new user.</param>
        /// <param name="email">The e-mail address for the new user.</param>
        /// <returns>A MembershipUser object populated with the information for the newly created user.</returns>
        MembershipUser CreateUser(string username, string password, string email);

        /// <summary>
        /// Verifies that the specified user name and password exist in the data source.
        /// </summary>
        /// <param name="username">The name of the user to validate. </param>
        /// <param name="password">The password for the specified user. </param>
        /// <returns>true if the specified username and password are valid; otherwise, false.</returns>
        bool ValidateUser(string username, string password);

        /// <summary>
        /// Gets information from the data source for a user. Do not update the last-activity date/time stamp for the user.
        /// </summary>
        /// <param name="username">The name of the user to get information for.</param>
        /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns>
        MembershipUser GetUser(string username);

        /// <summary>
        /// Gets user information from the data source based on the unique identifier for the membership user. Do not update the last-activity date/time stamp for the user.
        /// </summary>
        /// <param name="providerUserKey">The unique identifier for the membership user to get information for.</param>
        /// <returns>A MembershipUser object populated with the specified user's information from the data source.</returns>
        MembershipUser GetUser(object providerUserKey);

        /// <summary>
        /// Get the unique identifier for the membership user to get information for
        /// </summary>
        /// <param name="username">The name of the user to get information for.</param>
        /// <returns>The unique identifier for the membership user </returns>
        object GetProviderUserKey(string username);

        /// <summary>
        /// Gets a collection of membership users .
        /// </summary>
        /// <param name="emailOrName"></param>
        /// <returns></returns>
        MembershipUserCollection FindUsers(string emailOrName);

        /// <summary>
        /// Resets a user's password to a new, automatically generated password.
        /// </summary>
        /// <param name="username">The user to reset the password for. </param>
        /// <returns>The new password for the specified user.</returns>
        string ResetPassword(string username);

        /// <summary>
        /// Removes a user from the membership data source.
        /// </summary>
        /// <param name="username">The name of the user to delete.</param>
        /// <returns>true if the user was successfully deleted; otherwise, false.</returns>
        bool DeleteUser(string username);

        /// <summary>
        /// Clears a lock so that the membership user can be validated.
        /// </summary>
        /// <param name="username">The membership user whose lock status you want to clear.</param>
        /// <returns>true if the membership user was successfully unlocked; otherwise, false.</returns>
        bool UnlockUser(string username);

        /// <summary>
        /// Updates information about a user in the data source.
        /// </summary>
        /// <param name="user">A MembershipUser object that represents the user to update and the updated information for the user. </param>
        void UpdateUser(MembershipUser user);

    }
}
